# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Kenneth Endfinger <kaendfinger@gmail.com>

pkgname=throttled
pkgver=0.10.0
pkgrel=2
pkgdesc="Workaround for Intel throttling issues in Linux."
arch=('any')
url="https://github.com/erpalma/throttled"
license=('MIT')
depends=('python-dbus' 'python-gobject')
backup=('etc/throttled.conf')
install=$pkgname.install
source=("https://github.com/erpalma/$pkgname/archive/v$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('b89c467295bfc592d7b3ce0c4a41fedf436acf8067f8ef63d8596b92343ed8e04d371d065a9e35fdddba40772f12255c30960c2c46f0cbd5093bfc5e72fb4e18')

prepare() {
  sed -i "s|ExecStart=.*|ExecStart=/usr/lib/$pkgname/throttled.py|" $pkgname-$pkgver/systemd/throttled.service
}

build() {
  cd $pkgname-$pkgver
  python -m compileall *.py
}

package() {
  cd throttled-$pkgver
  install -Dm644 etc/throttled.conf "$pkgdir"/etc/throttled.conf
  install -Dm644 systemd/throttled.service "$pkgdir"/usr/lib/systemd/system/throttled.service
  install -Dm755 throttled.py "$pkgdir"/usr/lib/$pkgname/throttled.py
  install -Dm755 mmio.py "$pkgdir"/usr/lib/$pkgname/mmio.py
  cp -a __pycache__ "$pkgdir"/usr/lib/$pkgname/
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
